Namespace("org.wattdepot.gdata.makahiki");

// Creates a Bar Chart with a standard appearance.
org.wattdepot.gdata.makahiki.BarChart = function(configuration) {

  function draw(datatable, rows, columns, id, title, units) {
    element = document.getElementById(id);
    // Create a view consisting of the rows and columns.
    var chartView = new google.visualization.DataView(datatable);
    chartView.setColumns(columns);
    chartView.setRows(rows);

    // Create the BarChart
    var barChartColor = configuration.widgetHeaderColor;

    var chart = new google.visualization.BarChart(element);
    chart.draw(chartView, {width: configuration.barChartWidth,
			   height: configuration.barChartHeight,
                           backgroundColor : configuration.widgetBackgroundColor,
			   title: title,
			   titleColor : barChartColor,
			   legend: 'none',
                           colors : [barChartColor],
			   hAxis: {baselineColor: barChartColor, 
				   textColor : barChartColor,
				   titleColor : barChartColor,
				   minValue: '0', 
				   title: units},
			   vAxis: {textColor: barChartColor}
			  });
  }


  return {
    // Public interface to this function. 
    draw : draw
  };
}


